function doSearch() {
	$('#tt').datagrid('load', {
		groupName : $('#groupName').val()
	});
}

$(function() {
	$('#tt').datagrid({
		view : detailview,
		detailFormatter : function(index, row) {
			return '<div class="ddv" style="padding:5px 0"></div>';
		},
		onExpandRow : function(index, row) {
			var ddv = $(this).datagrid('getRowDetail', index).find('div.ddv');
			ddv.panel({
				border : false,
				cache : false,
				href : '/new/execution/getGroupDetail?groupId=' + row.id,
				onLoad : function() {
					$('#tt').datagrid('fixDetailRowHeight', index);
				}
			});
			$('#tt').datagrid('fixDetailRowHeight', index);
		}
	});
});

function add() {
	showMyWindow('新增', '/new/execution/add', 400, 200);
}

function edit() {
	var row = $('#tt').datagrid('getSelected');
	if (row) {
		showMyWindow('编辑', '/new/execution/' + row.id + '/edit', 400, 200);
	} else {
		showMsg(market.content.title, market.content.tips, alert);
	}
}

function del() {
	var row = $('#tt').datagrid('getSelected');
	if (row) {
		showConfirm(market.content.title, market.content.confirm, function() {
			$.post('/new/execution/' + row.id + '/delete', function(data) {
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					$("#tt").datagrid('reload');
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			});
		});
	} else {
		showMsg(market.content.title, market.content.tips, alert);
	}
}

function addMark() {
	var row = $('#tt').datagrid('getSelected');
	if (row) {
		showMyWindow('添加Mark', '/new/execution/' + row.id + '/addMark', 400, 200);
	} else {
		showMsg(market.content.title, market.content.tips, alert);
	}
}


//function editGroupMark(id) {
//	showMyWindow('编辑', '/new/execution/' + id + '/editGroupMark', 400, 200);
//}

function delGroupMark(id) {
	showConfirm(market.content.title, market.content.confirm, function() {
		$.post('/new/execution/' + id + '/deleteGroupMark', function(data) {
			if (data.return_code == '1') {
				top.showMsg(market.content.title, data.return_msg, alert);
				$("#tt").datagrid('reload');
			} else {
				$.messager.alert(market.content.title, data.return_msg);
			}
		});
	});
}
